﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MishraReader
{
    public static class SearchManager
    {
        public static void HighlightSearchText(string searchText, dynamic webBrowserDocument)
        {
            var htmlText = webBrowserDocument.documentElement.InnerHtml;

            var substitution = "<span style='background-color: rgb(255, 255, 0);'>" + searchText + "</span>";
            htmlText = htmlText.Replace(searchText, substitution);

            webBrowserDocument.Body.InnerHtml = htmlText;
        }

        public static void ResetHighlightSearchText(string searchText, dynamic webBrowserDocument)
        {
            var htmlText = webBrowserDocument.documentElement.InnerHtml;

            var substitution = "<SPAN style=\"BACKGROUND-COLOR: rgb(255,255,0)\">" + searchText + "</SPAN>";
            htmlText = htmlText.Replace(substitution, searchText);

            webBrowserDocument.Body.InnerHtml = htmlText;
        }
    }
}